<template>
  <div :style="{ ...styles }" class="position-full overHidden">
    <div class="widget-mask"></div>
    <iframe :src="state.values.url" class="width-100 height-100 border-none"></iframe>
  </div>
</template>
<script>
  export default {
    name: 'WebView',
    props: {
      widget: {
        type: Object,
        default: () => {
          return {};
        }
      }
    },
    data() {
      return {};
    },
    computed: {
      state() {
        if (!this.widget || !this.widget.UI.state) return;
        return this.widget.getCurrentState();
      },
      styles() {
        const {rect = {}} = this.widget;
        const styles = {};
        const {height: sHeight = 0} = rect;
        sHeight && (styles.lineHeight = `${sHeight}px`);
        return styles;
      },
    },
  };
</script>

<style scoped>
  .overHidden {
    overflow: hidden;
  }

  .border-none {
    border: none !important;
  }
  .widget-mask {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
  }
</style>
